﻿using System;
using System.Windows.Forms;
using TpBaseObjects.Interfaces;
using TpGlobalForms.Forms;
using TpOffice.Forms;
using TpOffice.Forms.BusinessCase;
using TpOffice.Interfaces;

namespace TpOffice.Controller {

    public class MainController : IController {

        #region Members

        private MainForm myForm;
        private const string errType = "Err";
        private const string logType = "Log";
        private const string logArea = "TpOffice.Controller.MainController";

        #endregion

        #region Constructor

        public MainController(ITecForm form) {
            myForm = form as MainForm;
        }

        #endregion

        #region Methods

        public void BeforeClosing(object sender, FormClosingEventArgs e) {
            DialogResult ok = MessageBox.Show("Wollen Sie Tec-Office wirklich beenden?", myForm.ToString(), MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (ok == DialogResult.No) {
                e.Cancel = true;
            }
        }

        public void ChangeUser(object sender, EventArgs e) {
            ChangeUserForm cuf = new ChangeUserForm();
            cuf.ShowDialog();
            this.myForm.SetUserLoginText(cuf.UserName, cuf.LoginTime);
        }

        public void CloseForm(object sender, EventArgs e) {
            MainForm frm = myForm as MainForm;
            frm.Close();
        }

        public void Dispose() {
        }

        public void OpenBusinessCasesShortListForm(object sender, EventArgs e) {
            BusinessCasesShortListForm bcForm = new BusinessCasesShortListForm();
            bcForm.Show();
        }

        public void OpenCashSaleForm(object sender, EventArgs e) {
            CashSaleForm csForm = new CashSaleForm();
            csForm.Show();
        }

        public void OpenImportForm(object sender, EventArgs e) {
            ImportBMDForm iForm = new ImportBMDForm();
            iForm.Show();
        }

        public void Save(IBaseObject myObject) {
            throw new NotImplementedException("MainController.Save");
        }

        public void ShowCommingSoon() {
            MessageBox.Show("Comming soon...", "Tec-Office", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
        }

        #endregion

    }
}
